/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package th.stripes.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author fikri
 */
public class PasswordValidatorUtil {
    
   private Pattern pattern;
	  private Matcher matcher;
 
	  private static final String PASSWORD_PATTERN = 
              "((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()]).{8,20})";
 
	  public PasswordValidatorUtil(){
		  pattern = Pattern.compile(PASSWORD_PATTERN);
	  }
 
	  /**
	   * Validate password with regular expression
	   * @param password password for validation
	   * @return true valid password, false invalid password
	   */
	  public boolean validate(final String password){
 
		  matcher = pattern.matcher(password);
		  return matcher.matches();
 
	  }
    
}
